package com.yc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.bean.TestCategory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestCategoryDao extends BaseMapper<TestCategory> {
    
    /**
     * 查询启用的分类列表，包含测评数量统计
     */
    @Select("SELECT tc.*, COUNT(pt.testId) as testCount " +
            "FROM testCategories tc " +
            "LEFT JOIN psychologicalTests pt ON tc.categoryId = pt.categoryId AND pt.status = 1 " +
            "WHERE tc.status = 1 " +
            "GROUP BY tc.categoryId " +
            "ORDER BY tc.sortOrder ASC")
    List<TestCategory> selectActiveCategoriesWithCount();
} 